package com.example.rbacmanage.service.app.impl;

import com.example.rbacmanage.entity.app.Tag;
import com.example.rbacmanage.mapper.app.TagMapper;
import com.example.rbacmanage.service.app.TagService;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class TagServiceImpl implements TagService{
    @Autowired
    private TagMapper tagMapper;
    @Override
    public void save(Tag tag) {
        tag.setCreateTime(new Date());
        tagMapper.insert(tag);
    }

    @Override
    public void remove(Long[] ids) {
        for (Long id:ids){
            tagMapper.del(id);
        }
    }

    @Override
    public void update(Tag tag) {
        tagMapper.update(tag);
    }

    @Override
    public List<Tag> getAll(Tag tag) {
        return tagMapper.list(tag);
    }

    @Override
    public PageInfo<Tag> getPage(Tag tag) {
        return new PageInfo<>(getAll(tag));
    }

    @Override
    public Tag getById(Long id) {
        return tagMapper.queryOneById(id);
    }

    @Override
    public Integer getCount(Tag tag) {
        return tagMapper.count(tag);
    }
}
